const express = require('express')
const app = express()
const https = require('https');
const fs = require('fs');
const appRouter = require('./routes')
const proxy = require('./proxy')
const { jwtRouter } = require('./jwt')
const CORS = require('cors')
require('./db/db')

app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(CORS())
// app.use('/', express.static('./web'))
app.use('/', express.static('./out'))
app.use('/static', express.static('./imgs'))//这里路径不能直接使用"/"开头
app.use('/api', appRouter)
app.use('/toApi', proxy)
app.use('/jwt', jwtRouter)
// app.listen(8080, () => { console.log('请访问http://localhost:8080') })

const options = {
    key: fs.readFileSync('./key.pem'),
    cert: fs.readFileSync('./cert.pem')
};
https.createServer(options, app).listen(8080, () => {
    console.log('请访问https://localhost:8080');
});
require('./webSocket')
